home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / source_code / dhtmlunl / dhtml.exe / CD Content / Chap17 / dun17_8.txt < prev    next >
Encoding:
Text File  |  1997-12-18  |  1.2 KB  |  46 lines

  1. <HTML>
  2.  
  3. <HEAD>
  4.  
  5.   <TITLE>Displaying Context-Sensitive Menus Using Mouse Position</TITLE>
  6.  
  7.   <STYLE TYPE="text/css">
  8.  
  9.     .contextMenu  { background-color: #CCCCCC; font-size: 9pt;
  10.  
  11.                     font-family: ms sans serif, helvetica, sans-serif;
  12.  
  13.                     line-height: 1.5em; padding: 10px;
  14.  
  15.                     border-style: solid; border-width: 1;
  16.  
  17.                     border-color: white; }
  18.  
  19.   </STYLE>
  20.  
  21.  
  22.  
  23.   <SCRIPT>
  24.  
  25.     function showDefaultMenu(event)
  26.  
  27.     {
  28.  
  29.       if (event.modifiers & Event.CONTROL_MASK)
  30.  
  31.       {
  32.  
  33.         document.defaultMenu.left = event.x;
  34.  
  35.         document.defaultMenu.top = event.y;
  36.  
  37.         document.defaultMenu.visibility = "show";
  38.  
  39.       }
  40.  
  41.     }
  42.  
  43.  
  44.  
  45.     function hideDefaultMenu(event)
  46.  
  47.     {
  48.  
  49.       document.defaultMenu.visibility = "hide";
  50.  
  51.     }
  52.  
  53.  
  54.  
  55.     document.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
  56.  
  57.     document.onmousedown = showDefaultMenu;
  58.  
  59.     document.onmouseup = hideDefaultMenu;
  60.  
  61.   </SCRIPT>
  62.  
  63. </HEAD>
  64.  
  65.  
  66.  
  67. <BODY>
  68.  
  69. <H2>Displaying Context-Sensitive Menus Using Mouse Position</H2>
  70.  
  71.  
  72.  
  73. <DIV ID=defaultMenu CLASS=contextMenu
  74.  
  75.      STYLE="position: absolute; visibility: hide; width: 100; ">
  76.  
  77.   Cut<BR>
  78.  
  79.   Copy<BR>
  80.  
  81.   Paste
  82.  
  83. </DIV>
  84.  
  85.  
  86.  
  87. </BODY>
  88.  
  89. </HTML>
  90.  
  91.